package org.yocastlong.mybatisplus.db.configuration;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.yocastlong.mybatisplus.db.dao.mapper.MybatisPlusMapperMark;

/**
 * @author 朱海龙
 * 2025/6/6 17:25
 */
@MapperScan(basePackageClasses = MybatisPlusMapperMark.class)
@Configuration
public class MybatisPlusConfiguration {

    @Autowired
    private MyTenantLineHandle tenantLineHandle;

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor     interceptor       = new MybatisPlusInterceptor();
        TenantLineInnerInterceptor tenantInterceptor = new TenantLineInnerInterceptor();
        tenantInterceptor.setTenantLineHandler(tenantLineHandle);
        interceptor.addInnerInterceptor(tenantInterceptor);
        return interceptor;
    }


}
